<layout name="Layout/layout" />
<div class="row">
	<div class="col-lg-12">
		<h1 class="page-header">考点</h1>
	</div>
	<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				编辑
			</div>
			<!-- /.panel-heading -->
			<div class="panel-body">
				<form role="form" action="{:U('Admin/Examcenter/editHandle')}" method="post">
					<div class="form-group">
						<label>名称</label>
						<input type="text" name="name" class="form-control" placeholder="考点的名称" value="{$info['name']}">
					</div>
					<div class="form-group">
						<label>考点所在省份:</label>
						</select>
						<foreach name="provincelist" item="v">
							<label class="checkbox-inline">
								<input name="province" type="radio" value="{$v['code']}"> {$v.name}
							</label>
						</foreach>
					</div>
					<div class="form-group">
						<label>允许参加考试的省份:</label>
						<foreach name="provincelist" item="v">
							<label class="checkbox-inline">
								<input class="allow" name="allow[]" type="checkbox" value="{$v['code']}" > {$v['name']}
							</label>
						</foreach>
					</div>
					<div class="form-group">
						<label>考试开始时间：</label>
						<input name="examstart" class="form-control" type="date" value="{:date('Y-m-d', $info['start_time'])}" id="examstartdatetimepicker">
					</div>
					<div class="form-group">
						<label>考试结束时间：</label>
						<input name="examend" class="form-control" type="date" value="{:date('Y-m-d', $info['end_time'])}" id="examenddatetimepicker">
					</div>
					<div class="form-group">
						<label>支持的专业：</label>
						<foreach name="majorlist" item="v">
							<label class="checkbox-inline">
								<input class="major" name="major[]" type="checkbox" value="{$v['id']}"> {$v['name']}
							</label>
						</foreach>
					</div>
                    <input type="hidden" name="id" value="{$info['id']}">
					<button type="submit" class="btn btn-default">保存</button>
					<button type="reset" class="btn btn-default">重置</button>
				</form>
			</div>
			<!-- /.panel-body -->
		</div>
		<!-- /.panel -->
	</div>
	<!-- /.col-lg-12 -->
</div>
<script>
    window.onload = function(){
        var province = {$info['fromprovince']};
        var allow = [{$info['forprovince']}];
        var major = [{$info['majors']}];
        console.log(allow);
        $('input[name=province]').each(function(){
            if(province == $(this).val()){
                $(this).attr('checked', 'checked');
            }
        });
        $('input[name="allow[]"]').each(function(){
            for(x in allow){
                if(allow[x] == $(this).val()){
                    $(this).attr('checked', 'true');
                }
            }
        });
        $('input[name="major[]"]').each(function(){
            for(x in major){
                if(major[x] == $(this).val()){
                    $(this).attr('checked', 'true');
                }
            }
        });
		$('input').iCheck({
	        checkboxClass: 'icheckbox_minimal-orange',
	        radioClass: 'iradio_minimal-orange',
	        increaseArea: '20%' // optional
	    });
    }
</script>
